MFA デバイス登録時エラーの対処法
2024.01.24
困っていること
IAM ユーザーの作成を行いました。 以下のエラーが発生し てMFA デバイス登録が出来ません。対処法を教えてください。
エラー例 1 User: arn:aws:iam::123456789012:user/IAM-MFA is not authorized to perform:iam:ListVirtualMFADevices on resource:arn:aws:iam123456789012:mfa/with an explicit deny in an identity-based policy
エラー例 2 User: arn:aws:iam::123456789012:user/IAM-MFA is not authorized to perform:iam:CreateVirtualMFADevice on resource:arn:aws:iam::123456789012:mfa/Test because no identity-based policy allows the iam:CreateVirtualMFADevice action
作成した IAM ユーザーにアタッチしているへアタッチしているカスタマー管理ポリシー
{ "Version": "2012-10-17", "Statement": [ { "Sid": "1234567890", "Effect": "Allow", "Action": [ "iam:CreateVirtualMFADevice", "iam:DeleteVirtualMFADevice", "iam:DeactivateMFADevice", "iam:EnableMFADevice", "iam:ResyncMFADevice", "iam:ListMFADevices" ], "Resource": [ "arn:aws:iam::*:mfa/${aws:username}", "arn:aws:iam::*:user/${aws:username}" ] }, { "Sid": "0987654321", "Effect": "Deny", "NotAction": [ "iam:CreateVirtualMFADevice", "iam:DeleteVirtualMFADevice", "iam:DeactivateMFADevice", "iam:EnableMFADevice", "iam:ResyncMFADevice", "iam:ListMFADevices", "iam:ChangePassword", "iam:GetAccountPasswordPolicy" ], "Resource": "*", "Condition": { "BoolIfExists": { "aws:MultiFactorAuthPresent": "false" } } } ] }
どう対応すればいいの?
現在、これまで 1 つしか登録できなかった IAM ユーザー もしくは root アカウントユーザへの MFA デバイスを、最大 8 個まで登録が可能となっています。
そのため、これまでは MFA デバイス登録時に MFA デバイスへの名づけが不要であったが、名づけが必要になっています。
もし、何らかの形で、以前利用していたカスタマー管理ポリシーを流用している場合などは、ドキュメントを参考に該当のカスタマー管理ポリシーを以下へ修正するなど対応をしてください。
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowListActions", "Effect": "Allow", "Action": [ "iam:ListUsers", "iam:ListVirtualMFADevices" ], "Resource": "*" }, { "Sid": "AllowUserToCreateVirtualMFADevice", "Effect": "Allow", "Action": [ "iam:CreateVirtualMFADevice" ], "Resource": "arn:aws:iam::*:mfa/*" }, { "Sid": "AllowUserToManageTheirOwnMFA", "Effect": "Allow", "Action": [ "iam:EnableMFADevice", "iam:GetMFADevice", "iam:ListMFADevices", "iam:ResyncMFADevice" ], "Resource": "arn:aws:iam::*:user/${aws:username}" }, { "Sid": "AllowUserToDeactivateTheirOwnMFAOnlyWhenUsingMFA", "Effect": "Allow", "Action": [ "iam:DeactivateMFADevice" ], "Resource": [ "arn:aws:iam::*:user/${aws:username}" ], "Condition": { "Bool": { "aws:MultiFactorAuthPresent": "true" } } }, { "Sid": "BlockMostAccessUnlessSignedInWithMFA", "Effect": "Deny", "NotAction": [ "iam:CreateVirtualMFADevice", "iam:EnableMFADevice", "iam:ListMFADevices", "iam:ListUsers", "iam:ListVirtualMFADevices", "iam:ResyncMFADevice" ], "Resource": "*", "Condition": { "BoolIfExists": { "aws:MultiFactorAuthPresent": "false" } } } ] }
作成した IAM ユーザーにアタッチしているへアタッチしているカスタマー管理ポリシーの修正例
{ "Version": "2012-10-17", "Statement": [ { "Sid": "1234567890", "Effect": "Allow", "Action": [ "iam:CreateVirtualMFADevice", "iam:DeleteVirtualMFADevice", "iam:DeactivateMFADevice", "iam:EnableMFADevice", "iam:ResyncMFADevice", "iam:ListMFADevices" ], "Resource": [ "arn:aws:iam::*:mfa/${aws:username}", "arn:aws:iam::*:user/${aws:username}", "arn:aws:iam::*:mfa/*" ← 追加 ] }, { "Sid": "0987654321", "Effect": "Deny", "NotAction": [ "iam:CreateVirtualMFADevice", "iam:DeleteVirtualMFADevice", "iam:DeactivateMFADevice", "iam:EnableMFADevice", "iam:ResyncMFADevice", "iam:ListMFADevices", "iam:ChangePassword", "iam:GetAccountPasswordPolicy" ], "Resource": "*", "Condition": { "BoolIfExists": { "aws:MultiFactorAuthPresent": "false" } } } ] }